﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KeepAnimals.Library
{
    public static class ExtensionOfObject
    {
        public static string ToStringDetailed(this object target)
        {
            var sb = new StringBuilder();
            var query = from prop in target.GetType().GetProperties()
                        select new
                        {
                            PropertyName = prop.Name,
                            PropertyValue = target.GetPropertyValue(prop.Name)
                        };
            foreach (var info in query)
            {
                sb.AppendFormat("{0}: {1} {2}",
                                info.PropertyName,
                                info.PropertyValue,
                                "\r\n");
            }

            return sb.ToString();
        }
    }
}